﻿@model List<Wicresoft.UnifyShow.Business.DocumentModel>
@{
    ViewBag.Title = "常用资源列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section ScriptAndCss{
    <link href="@Url.Content("~/Content/css/plan.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/json3.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/plan.js")" type="text/javascript"></script>
}
<script type="text/javascript">
    var DateFormate = function (value, row, index) {
        if (value) {
            return value.DateStringConvert('yyyy-MM-dd');
        }
    };

    var Upfiles = function (value, row, index) {
        if (value) {

            return "<a href='" + row["Url"] + "'>" + value + "</a>";
        }
    };

    var SearchResource = function () {
        $('#MySearchedList').datagrid({
            pageList: [10],
            pageNumber: 1,
            queryParams: { param: $("#keywords").val() },
            onLoadSuccess: function (data) {
                $('.datagrid-btable').find('td').each(function () {
                    $(this).attr('title', $(this).text());
                });
            },
            onDblClickRow: function (rowIndex, rowData) {
                var rnd = (new Date()).getMilliseconds() + "" + parseInt(Math.random() * 10000);
                $.ajax({
                    url: 'ComResource/GetURL',
                    data: { ID: rowData["ID"], nocatch: rnd },
                    success: function (result) {
                        window.open(encodeURI(result) + "catchid=" + rnd);
                    }

                });
            }
        });

        var p2 = $('#MySearchedList').datagrid('getPager');
        $(p2).pagination({
            beforePageText: '第',
            afterPageText: '页&nbsp;共&nbsp;{pages}&nbsp;页',
            displayMsg: '当前显示{from} - {to}&nbsp;条记录&nbsp;共&nbsp;{total}&nbsp;条记录'

        });

    };
</script>
<div class="index_lr">
    <div class="index_lrA_title ui-icons">
        <h3>
            常用资源搜索</h3>
    </div>
    <div class="index_pt_bg">
        <label>
            关键字：</label>
        <input type="text" id="keywords" name="keywords" />
        <input type="button" value="搜索" class="searchBtn" onclick="SearchResource();" />
    </div>
    <div class="index_pt_bg" id="ListDocuments">
    </div>
    <div class="easyui-panel" title="常用资源列表" data-options="tools:'#todoMore'">
        <table id="MySearchedList" style="height: 250px;" class="easyui-datagrid" pagination="true"
            url="/ComResource/PostSearchResource" fitcolumns="true" singleselect="true">
            <thead>
                <tr>
                    <th field="ID">
                        ID
                    </th>
                    <th field="DName" width="10%" sortable="true">
                        名称
                    </th>
                    <th field="Keywords" width="20%" sortable="true">
                        关键字
                    </th>
                    <th field="FileName" width="40%" formatter="Upfiles" sortable="true">
                        文件
                    </th>
                    <th field="CreateTime" width="10%" formatter="DateFormate" sortable="true">
                        发布时间
                    </th>
                    <th field="Submitter" width="10%" sortable="true">
                        发布人
                    </th>
                    <th field="Priority" width="10%" sortable="true">
                        操作
                    </th>
                </tr>
            </thead>
        </table>
    </div>
</div>
